{% extends "base.html" %}

{% block title %}抽题系统 - 首页{% endblock %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-body">
                    <h2 class="card-title text-center mb-4">抽题系统</h2>
                    <div class="form-group mb-4">
                        <label for="studentId">学号</label>
                        <input type="text" class="form-control" id="studentId" placeholder="请输入学号">
                    </div>
                    <div class="text-center">
                        <button class="btn btn-primary btn-lg" onclick="drawQuestion()">抽题</button>
                    </div>
                    <div id="questionDisplay" class="mt-4" style="display: none;">
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <h4 class="mb-0">题目内容：</h4>
                            {% if configs.get('retry_limit', 3) > 0 %}
                            <button class="btn btn-warning" onclick="retryDraw()">
                                <i class="bi bi-arrow-repeat me-1"></i>重新抽取
                                <span class="badge bg-light text-dark ms-2" id="retryCount" data-max-retries="{{ configs.get('retry_limit', 3) }}">0/{{ configs.get('retry_limit', 3) }}</span>
                            </button>
                            {% endif %}
                        </div>
                        <div id="questionContent"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Error Modal -->
<div class="modal fade" id="errorModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header bg-danger text-white">
                <h5 class="modal-title">提示</h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <p id="errorMessage"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block styles %}
<style>
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);
}

.card-header {
    border-radius: 15px 15px 0 0 !important;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.25rem;
}

.btn-warning {
    background-color: #f6c23e;
    border-color: #f6c23e;
    color: #fff;
}

.btn-warning:hover {
    background-color: #f4b619;
    border-color: #f4b619;
    color: #fff;
}

.question-item {
    background-color: #f8f9fc;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.question-item:hover {
    transform: translateX(5px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.question-content {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.modal-content {
    border: none;
    border-radius: 15px;
}

.modal-header {
    border-radius: 15px 15px 0 0;
}

.text-primary {
    color: #4e73df !important;
}

.text-success {
    color: #1cc88a !important;
}

.text-info {
    color: #36b9cc !important;
}

.text-danger {
    color: #e74a3b !important;
}

.bg-primary {
    background-color: #4e73df !important;
}

.bg-danger {
    background-color: #e74a3b !important;
}

.badge {
    font-size: 0.875rem;
    padding: 0.35em 0.65em;
    border-radius: 0.25rem;
}
</style>
{% endblock %}

{% block scripts %}
  <script src="{{ url_for('static', filename='js/api.js') }}"></script>
{% endblock %} 